﻿using Microsoft.Office.Tools.Ribbon;

namespace HualongExcel.Extensions
{
    public static class RibbonComboBoxExtensions
    {

        public static int GetCurrentIndex(this RibbonComboBox comboBox)
        {
            for (int i = 0; i < comboBox.Items.Count; i++)
            {
                if (comboBox.Items[i].ToString() == comboBox.Text)
                    return i;
            }
            return -1;
        }


        public static void SetIndex(this RibbonComboBox comboBox, int index)
        {
            if (index >= comboBox.Items.Count || index < 0) return;
            comboBox.Text = comboBox.Items[index].ToString();
        }
    }
}
